<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>初始vue</title>
    <script type="text/javascript"  src="../js/vue.js"></script> 

</head>


<body>
    <div id="root">
        <h2 :style="{opacity}">欢迎学习vue </h2>
        <button @click="add">点击n++</button>
        <h1>n:{{n}}</h1>

        <button @click="bye">点我销毁</button>
    </div>
   
</body>

<script type="text/javascript">
   Vue.config.productionTip=false;
 
    let vm =new Vue({
        el:"#root",
        data:{
            opacity:1,
            n:1
        }, 
        methods: {
          add(){
            console.log("add被调用")
            this.n++
          }
          ,
          bye(){
            this.$destroy()
          }
        },
        watch:{
            n(){
                console.log("n变了")
            }
        },
     
        beforeCreate(){
            console.log("beforeCreated")
            console.log(this)
        },
        created(){
            console.log("created")
            console.log(this)
        },
        beforeMount(){
            console.log("beforeMount")
            console.log(this)
        },
        mounted(){
            console.log("mounted")
            console.log(this.$el instanceof HTMLElement)
            
        },
        beforeUpdate() {
            console.log(this.n)
        },
        updated() {
            console.log(this.n)
        },
        //在销毁生命周期改数据是不会生效的
        beforeDestroy() {
            console.log('beforeDestroy')

            console.log(this.n)
        },
        destroyed() {
            console.log('destroyed')
            console.log(this.n)
			debugger
        }
    })
 

    
</script>
</html>